{
  "properties" : { },
  "id" : "dabc8a150c414241b87fdb7bbdd3d26f",
  "script" : null,
  "groupId" : "bcdec4ef1ba74815bea2c09a20056b65",
  "name" : "查询用户",
  "createTime" : null,
  "updateTime" : 1736694322635,
  "lock" : null,
  "createBy" : "管理员",
  "updateBy" : "可辉",
  "path" : "list",
  "method" : "GET",
  "parameters" : [ {
    "name" : "username",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "name",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "unitId",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : "1",
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "limit",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "Integer",
    "type" : null,
    "defaultValue" : "10",
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "page",
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "Integer",
    "type" : null,
    "defaultValue" : "0",
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "options" : [ {
    "name" : "permission",
    "value" : "system:uhgl",
    "description" : "允许拥有该权限的访问",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ],
  "requestBody" : "",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 200,\n    \"msg\": \"success\",\n    \"data\": {\n        \"total\": 11,\n        \"list\": [\n            {\n                \"userId\": 1001,\n                \"name\": \"管理员\",\n                \"memo\": \"ps: 管理系统的人员\",\n                \"username\": \"admin\",\n                \"password\": \"$2a$10$6anWZi7CFQEqRLywv.X3vO/ejCSA3wx9/iKbsaiOw9Hny.3lR/moq\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1001,\n                \"creatorName\": \"管理员\",\n                \"createTime\": \"2023-10-19 22:37:38\",\n                \"updateTime\": \"2024-03-16 22:02:14\",\n                \"roleName\": \"超管\"\n            },\n            {\n                \"userId\": 1003,\n                \"name\": \"可辉\",\n                \"memo\": \"ps: 个人账户\",\n                \"username\": \"kehui\",\n                \"password\": \"$2a$10$EwG0JsVXMf7hhcGKyEinE.ZkcjPorja0Iuj4iQnjJ/oVssX.PO4Ka\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1001,\n                \"creatorName\": \"管理员\",\n                \"createTime\": \"2024-11-11 17:22:55\",\n                \"updateTime\": \"2025-01-13 06:41:17\",\n                \"roleName\": \"超管\"\n            },\n            {\n                \"userId\": 1002,\n                \"name\": \"游客\",\n                \"memo\": \"ps: 公开对外用户。\",\n                \"username\": \"visitor\",\n                \"password\": \"$2a$10$8S8rKcG5gqn/1WxdP8xC2uMwD4Vt42xonQEXk01xqsNdMM2JG4Upi\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1001,\n                \"creatorName\": \"管理员\",\n                \"createTime\": \"2023-10-19 23:18:38\",\n                \"updateTime\": \"2024-03-18 23:14:52\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1004,\n                \"name\": \"测试1号\",\n                \"memo\": \"ps: 这是测试数据\",\n                \"username\": \"test1\",\n                \"password\": \"$2a$10$VeRWL6ExVzBhI8gFasbN6eU.SpZlIrNPYdFD4gcmitnm/PapAPaBG\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-12 22:47:18\",\n                \"updateTime\": \"2025-01-13 06:03:00\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1007,\n                \"name\": \"tt\",\n                \"memo\": \" ps: 测试添加的\",\n                \"username\": \"tt1\",\n                \"password\": \"$2a$10$nK9ewdcezUcFh9vvd1caMuRuhJaGmaXITjJK.XUnMWYdvmrGFBfGG\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-12 23:56:36\",\n                \"updateTime\": \"2025-01-13 06:41:34\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1010,\n                \"name\": \"tt2\",\n                \"memo\": \" \",\n                \"username\": \"tt2\",\n                \"password\": \"$2a$10$STV3mJfEvT/zvLB4XtDmvujUb.ehj7racw8Gh8O6g0HBT0cjJcH.S\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-13 06:57:22\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1011,\n                \"name\": \"tt3\",\n                \"memo\": \" \",\n                \"username\": \"tt3\",\n                \"password\": \"$2a$10$dKU5Fd2IhRC/iAKnb2NEYuKc77u9jgWQ1WDz1LTfZlWOGdo59ydia\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-13 06:57:40\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1012,\n                \"name\": \"tt4\",\n                \"memo\": \" \",\n                \"username\": \"tt4\",\n                \"password\": \"$2a$10$zlzAXS9hZhewDWc6dRmSDuDHTfp12kYeBTc4HmcKUZE.JWSHb1L8K\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-13 06:57:47\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1013,\n                \"name\": \"tt5\",\n                \"memo\": \" \",\n                \"username\": \"tt5\",\n                \"password\": \"$2a$10$jfIhBaj5z9.J0lmo9PK2g.Uv2hHHM3iAwgoAUWEinChkBl3gfkK7u\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-13 06:57:59\",\n                \"roleName\": \"游客\"\n            },\n            {\n                \"userId\": 1014,\n                \"name\": \"tt6\",\n                \"memo\": \" \",\n                \"username\": \"tt6\",\n                \"password\": \"$2a$10$HVTggdYMmTf8HW6fmhDGfeK57H0V0pQRCWmxO3klm0qWoFd26EcOu\",\n                \"nonLock\": 1,\n                \"nonExpired\": 1,\n                \"nonExpiredC\": 1,\n                \"isEnabled\": 1,\n                \"creatorId\": 1003,\n                \"creatorName\": \"可辉\",\n                \"createTime\": \"2025-01-13 06:58:07\",\n                \"roleName\": \"游客\"\n            }\n        ]\n    }\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import com.alibaba.fastjson.JSONObject;

var seSql = """
    SELECT 
        sur.*, sr.role_name FROM sys_user as sur 
        LEFT JOIN sys_unit_user_role as suur ON sur.user_id = suur.user_id
        LEFT JOIN sys_role AS sr ON sr.role_id = suur.role_id
    WHERE 
        suur.unit_id = #{unitId}
""";


if(username){
    seSql = seSql + " and username like '%${username}%'";
}
if(name){
    seSql = seSql + " and name like '%${name}%'";
}

if(orderProperty){
    seSql = seSql + " ORDER BY sur.`"+orderProperty+"` " + (orderSort? 'ASC': 'DESC');
}

return db.admin.page(seSql, limit, (page-1) * limit);